//
//  YGFoodItemListTableViewCell.m
//  yuanshangyiliao
//
//  Created by icholab on 2021/4/26.
//

#import "YGFoodItemListTableViewCell.h"

@interface YGFoodItemListTableViewCell ()
@property (nonatomic, strong) UILabel  *firLabel;
@property (nonatomic, strong) UILabel  *secLabel;
@property (nonatomic, strong) UILabel  *thirLabel;


@end
@implementation YGFoodItemListTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style
                reuseIdentifier:reuseIdentifier];
    if (self) {
        [self addSubview:self.firLabel];
        [self addSubview:self.secLabel];
        [self addSubview:self.thirLabel];
        
        [self.firLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.top.bottom.mas_equalTo(self);
            make.width.mas_equalTo(self.mas_width).multipliedBy(1/3.0);
        }];
        
        [self.secLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.mas_equalTo(self);
            make.width.mas_equalTo(self.firLabel.mas_width);
            make.left.mas_equalTo(self.firLabel.mas_right);
        }];
        
        [self.thirLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.mas_equalTo(self);
            make.width.mas_equalTo(self.firLabel.mas_width);
            make.left.mas_equalTo(self.secLabel.mas_right);

        }];
        
        UIView *lineView = [[UIView alloc] init];
        lineView.backgroundColor = UIColorFromRGB(0x37C8D7);
        [self addSubview:lineView];
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.right.left.mas_offset(0);
            make.height.mas_offset(0.5);
        }];;
    }
    return self;
}

- (void)configureModel:(YGServerItemModel *)model{
    self.firLabel.text = model.ingredient;
    self.secLabel.text = model.gContent;
    self.thirLabel.text = model.unit;
}


- (UILabel *)firLabel{
    if (!_firLabel) {
        _firLabel = [[UILabel alloc] init];
        _firLabel.textColor = UIColorFromRGB(0x333333);
        _firLabel.textAlignment = NSTextAlignmentCenter;
        _firLabel.font = [UIFont systemFontOfSize:12];

    }
    return _firLabel;
}

- (UILabel *)secLabel{
    if (!_secLabel) {
        _secLabel = [[UILabel alloc] init];
        _secLabel.textColor = UIColorFromRGB(0x333333);
        _secLabel.textAlignment = NSTextAlignmentCenter;
        _secLabel.font = [UIFont systemFontOfSize:12];

    }
    return _secLabel;
}

- (UILabel *)thirLabel{
    if (!_thirLabel) {
        _thirLabel = [[UILabel alloc] init];
        _thirLabel.textColor = UIColorFromRGB(0x333333);
        _thirLabel.textAlignment = NSTextAlignmentCenter;
        _thirLabel.font = [UIFont systemFontOfSize:12];
    }
    return _thirLabel;
}

@end
